package com.test.mylotterysystem.dao.Mapper;

import com.test.mylotterysystem.dao.DO.Encrypt;
import com.test.mylotterysystem.dao.DO.UserDO;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;

@Mapper
public interface UserMapper {

    @Select("select count(*) from user where user_name = #{name}")
    int checkUserName(String name);

    @Select("select count(*) from user where email = #{mail}")
    int checkUserMail(String mail);

    @Select("select count(*) from user where phone_number = #{phoneNumber}")
    int checkPhone(String phoneNumber);

    @Insert("insert into user (user_name, email, phone_number, password, identity) " +
            "values (#{userName},#{email},#{phoneNumber},#{password},#{identity})")
    @Options(useGeneratedKeys = true,keyColumn = "id",keyProperty = "id")
    void insertUserInfo(UserDO userDO);

    @Select("select * from user where phone_number = #{phoneNumber};")
    UserDO selectByPhoneNumber(Encrypt phoneNumber);
}
